package com.gitee.wsl.mathematics.vector.bool.ext

import com.gitee.wsl.mathematics.number.compareTo
import com.gitee.wsl.mathematics.vector.vec4.Vector4
import com.gitee.wsl.mathematics.vector.bool.BooleanVector4

fun <T:Number> lessThan(a: Vector4<T,*>, b: T) = BooleanVector4(a.x < b, a.y < b, a.z < b, a.w < b)
fun <T:Number> lessThan(a: Vector4<T,*>, b: Vector4<T,*>) = BooleanVector4(a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w)
fun <T:Number> lessThanEqual(a: Vector4<T,*>, b: T) = BooleanVector4(a.x <= b, a.y <= b, a.z <= b, a.w <= b)
fun <T:Number> lessThanEqual(a: Vector4<T,*>, b: Vector4<T,*>) = BooleanVector4(a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w)
fun <T:Number> greaterThan(a: Vector4<T,*>, b: T) = BooleanVector4(a.x > b, a.y > b, a.z > b, a.w > b)
fun <T:Number> greaterThan(a: Vector4<T,*>, b: Vector4<T,*>) = BooleanVector4(a.x > b.y, a.y > b.y, a.z > b.z, a.w > b.w)
fun <T:Number> greaterThanEqual(a: Vector4<T,*>, b: T) = BooleanVector4(a.x >= b, a.y >= b, a.z >= b, a.w >= b)
fun <T:Number> greaterThanEqual(a: Vector4<T,*>, b: Vector4<T,*>) = BooleanVector4(a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w)
fun <T:Number> equal(a: Vector4<T,*>, b: T) = BooleanVector4(a.x == b, a.y == b, a.z == b, a.w == b)
fun <T:Number> equal(a: Vector4<T,*>, b: Vector4<T,*>) = BooleanVector4(a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w)
fun <T:Number> notEqual(a: Vector4<T,*>, b: T) = BooleanVector4(a.x != b, a.y != b, a.z != b, a.w != b)
fun <T:Number> notEqual(a: Vector4<T,*>, b: Vector4<T,*>) = BooleanVector4(a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w)

infix fun <T:Number> Vector4<T,*>.lt(b: T) = BooleanVector4(x < b, y < b, z < b, w < b)
infix fun <T:Number> Vector4<T,*>.lt(b: Vector4<T,*>) = BooleanVector4(x < b.x, y < b.y, z < b.z, w < b.w)
infix fun <T:Number> Vector4<T,*>.lte(b: T) = BooleanVector4(x <= b, y <= b, z <= b, w <= b)
infix fun <T:Number> Vector4<T,*>.lte(b: Vector4<T,*>) = BooleanVector4(x <= b.x, y <= b.y, z <= b.z, w <= b.w)
infix fun <T:Number> Vector4<T,*>.gt(b: T) = BooleanVector4(x > b, y > b, z > b, w > b)
infix fun <T:Number> Vector4<T,*>.gt(b: Vector4<T,*>) = BooleanVector4(x > b.x, y > b.y, z > b.z, w > b.w)
infix fun <T:Number> Vector4<T,*>.gte(b: T) = BooleanVector4(x >= b, y >= b, z >= b, w >= b)
infix fun <T:Number> Vector4<T,*>.gte(b: Vector4<T,*>) = BooleanVector4(x >= b.x, y >= b.y, z >= b.z, w >= b.w)
infix fun <T:Number> Vector4<T,*>.eq(b: T) = BooleanVector4(x == b, y == b, z == b, w == b)
infix fun <T:Number> Vector4<T,*>.eq(b: Vector4<T,*>) = BooleanVector4(x == b.x, y == b.y, z == b.z, w == b.w)
infix fun <T:Number> Vector4<T,*>.neq(b: T) = BooleanVector4(x != b, y != b, z != b, w != b)
infix fun <T:Number> Vector4<T,*>.neq(b: Vector4<T,*>) = BooleanVector4(x != b.x, y != b.y, z != b.z, w != b.w)

fun <T:Number> any(v: BooleanVector4) = v.x || v.y || v.z || v.w
fun <T:Number> all(v: BooleanVector4) = v.x && v.y && v.z && v.w